class DashboardController < ApplicationController
  before_filter :check_authorization
  layout 'company',:except=>['custom_logs']

  def index
    logger.error "==========================="
    logger.error cookies[:user_id]
    logger.error "==========================="
    if @cur_user.account_owner? or @cur_user.global_user?
      @projects = @cur_user.company.active_projects 
    elsif @cur_user.supper?
      url = request.subdomains
      url = url.join(".") if url.size > 1
      url = "abb" if RAILS_ENV == 'development'
      @company = Company.find(:first,:conditions=>["url = ?",url])
      @projects = @company.active_projects    
    else
      @projects = @cur_user.active_projects    
    end
      @cur_user.login_at = Time.now
      @cur_user.save
    @page_title = "Dashboard".t
  end
  def custom_logs
    if @cur_user.supper?
      url = request.subdomains
      url = url.join(".") if url.size > 1
      url = "abb" if RAILS_ENV == 'development'
      @company = Company.find(:first,:conditions=>["url = ?",url])
      @projects = @company.active_projects    
    elsif @cur_user.account_owner? or @cur_user.global_user?
      @projects = @cur_user.company.active_projects 
    else
      @projects = @cur_user.active_projects    
    end
  end
end
